Searching is finished! Also some minor refactoring.