Fixed Error message bugs and added better diagnostics