Implemented all of Jonathan's changes and bug fixes