Clean up DOM code a bit.