Simpler offset calculation and fix getCurrViewportRect calculation