Further cleanup of formatting, whitespace, comments, and javadoc. Also privatized some functions that don't require public access