add support for flipped tiles
fix jshint errors