Better documentation
Fixed minor mistake in error message
Fixes for some corner-case situations