Some bug fixes on viewport calculations. closes #8