Add documentation and more specific error messages