Implemented the toric code, cleaned things up a bit.