Added viewport methods.
Moved helper functions to util.js