Ported model and spec code from earlier version of app.