Added support for custom fields

I'm not proud of this implementation, but it's better than nothing.
Still I'm open for suggestions.