Removed unnecessary classes. Moved some code around and added comments