some javadoc and tidying up