Fix bugs with viewport