Added 500 internal error and DB integrity management