Cleaned up code + JavaDoc