Added Java docs and cleaned up code