Error messages and bug fix