Updated javadoc, fixed indentation, organize imports and some minor refactoring. Original Pull Request: #169