This is getting pretty deeply indented. Perhaps soon time to break something out into a partial..?