Cleaned up object encoding.