Corrected the output of error messages
Added in the database and cleaned some comments