Issue 3402

@phtaylor viewport callbacks + refactoring