First commit in a long time. Much needed refactoring.
Added some of the missing files.