First unstable implementation of search engine, added API functions, code cleanup