Refactor renderElement and renderForm functions

Remove Control.Monad(void) dependency.
Reduce code duplication in renderForm.