Switched to object oriented design. Code cleanup. Removed unused funcitons.