Fixed setting of current database; Improved exceptions