Added some javadocs and a bit of refactoring.
Added some javadocs
Added some javadocs
Added some javadocs
Merge ghorigin/master