Fix bugs found

Fix error messages.