Major changes to fit OOP requirements

New class structure and code improvements.