Custom elements overhaul

Not yet ready to merge -- this is just to track progress.