Added piecemask and minor perf upgrades