Revert "Went back to the vector based z-restoration. Can't shake the shakiness."

This reverts commit 25992b0b66f27ecf585dcd222e82000a0ebfefa0.