divide classes to separate files, fix some coding style stuff