update models.

fix mode bugs and refactor model data structures.