add support for custom fields and cleanup