Move creating viewer stage out of JS.