Fix shuffleplanes bugs, add test