checked and improved error messages, documentation