Cleaned up the measurements code.