Cleaned up correlation code.