Fixed a few errors. Removed unnecessary helper functions