Improved checks and error reporting