Changed basic structure of classes. Constructed private functions and a more clean design.