add error messages and some bugfix