Added better error messaging.