Start refactoring static HTML completions

Much smaller code; not quite finished yet.