Notes taking and notes management Problem 1

I have been struggling coming out an efficient way to take notes while reading papers, one commonly-used way is annotate the paper while reading, but some issues include


These notes are hard to organize since they are distributed through the text.
There notes usually could not include mathematical formula. However, it is the major part of my notes.
When paper is lost in thousands of papers, it is impossible to recover them.


Therefore, I tried to use stand-alone notes written in markdown, but problem 2 arises.

Problem 2

As mentioned in problem 1, there are so many papers (and notes) I need to keep and it is just not feasible to keep hierarchy of folders, which could have up to 5 or even 10 hierarchy. Even though problem 1 is resolved, an effective and easy way to search and retrieve previous papers and notes is still needed. 

Finally, any input about your solutions is appreciated.
I like taking notes separately in an infinitely zoomable online outliner and include hyperlinks there to the papers in question. Dynalist supports KaTeX and Markdown, and there's a MathJax Chrome extension for WorkFlowy called MathFlowy, although it's broken right now since WorkFlowy redesigned. WorkFlowy and Dynalist also have a lot of user-defined tweaks on Stylish. There's a zillion other outliner options, both online and offline, but I personally like these two. 

Since you can hyperlink to other items in the outline and tag individual items, it's easier to keep stuff both organized and connected. It's also possible to export portions of the outline to plain text or RTF.

EDIT: I forgot to mention Gingko, which supports both Markdown and MathJax and has a variety of export formats. I haven't used it in a while, but it's an interesting UI which is especially useful for organizing projects and long notes. The dev also recently released a desktop version if you prefer something that works offline.