Added some validation checks in models, minor bug fixes.