Search function improvement.
Refactoring.
Main class.