Changed the way viewdir is handled