Code refactoring

sorted classes into respective folders
fixed a few bugs