cleanup defintions and add cleaner error messages