Major changes in code structure

Made the code all together more modular.  Also added a lot of necessary boilerplate.