Refactored error messages and added delete code.