Some minor fixes, and error handling.