Added some java doc and cleaned code a bit