fixed some typechecking bugs. Added user feedback when fields are invalid.