Clean up, modernize and optimize some old legacy cruft...