Improve javadocs
Improve error handling.