Many improvements in searching sources.

Fixed bugs in last points.
Function sorted logically.
Removed unused imports.