Model validation, bug fixes