Refactored error messaging.