Move message classes to separate file.

Simplify conversion between messages and models.

Lint fixes.