Cleaned up Code and placed functions for each class into source files.