Refactored class and method definitions
Bugfixes