Cleaned up code and added more annotations for javadocs