Stencil implementation + two fixes