Fix many piston related bugs. (From last commit)