Improved error messages and fixed bad printfs