Made a bunch of changes to clean and make classes safer.
Added encoder to close #12