Cleaned up some functions, added public functions and made things a little safer