Model code refactor work in progress.

Change-Id: I2358a98e14f9f99a4a7562171208c22a9e66c211