comments and cleanup
change exception type, add test
more comments and simplification