added stencil functionality. changed flush to work with stencilling, seems to work