More refactor and cleanup.
Changed ViewType by enumeration.
More refactor.