Fixed formatting and wrote some javadoc