A lot of refactoring.
Removed unused methods.