Replaced template by theme function
Moved rendering of custom form elements into preprocess function