Major refactor of entire code base to clean it up