Reorganizing some files, refactoring, adding some additional checks, optimizing lookups.
Merge pull request #2 from kovshenin/patch-1

Reorganizing some files, refactoring...