Updated error messages, fixed some bugs