fix for viewtypes: viewtype must be <= viewtypecount
more viewtype related fixes