Changed errors to give codes and relevant messages