@ Roland
Small bug in the importing section of your custom fields code snippet. Corrected version attached.
Hope this helps!