Ported model validation code
Renamed exception name; ported model validation code