Bug fixes, cleared partial code and added partial javadoc