Cleaned up code, commented more

Also included Professor Beck's additional functions, but did not use
them