Changed the code structure so that it works with automatic class loading

Also removed an unused function.