Replace panics with errors
Documents, and a fix for bugs discovered by the example