Clean up element code & add more docs