Clean up element creation code.

Fixes #10