Refactor complete. Cartesian, spinor, and KS state examples now working.