Cleaned up the cycle encoding stuff.