Move compacting read/write methods to util class.
Added in method for converting items to a safe string.