Improve the error messages for illegal state exceptions