Minor bug fixes and improved error messages.