Added and improved error checks and responses.