Improved debugging and errors