Clean up the class code and add some (meaningful) comments