Fix viewport code