fixes #509 by adding layer to the list of variables inside the stage _resizeDOM method.  Otherwise it is hoisted and defined globally