Refactored code, bugfix API version, included javadoc