Add missing javadoc.
Improve error handling.
Use enum instead of strings in usage.
Add missing javadoc.