error messages and main tidy