Added exceptions and fixed javadoc