Revert "multiple performance improvements"

This reverts commit 37e5eb33d7f7986597216d1cfb62b442cce2277c.
Revert "Merge branch 'master' into noPiece"

This reverts commit 04a1228682dc3410dc313ad7321acd6a9f72aba9, reversing
changes made to 194bc76709d7decafce0b250ae9544eeb10fbe46.