Split code into classes

Code is now split into multiple classes.
Main file class size was cut in half.