Added javadoc and rearranged the API.