Code cleanup and javadoc for server