Improved error message and comments