Re: all the corner cases, it's probably best to write a simple first draft and see if there are any problems. There may be fewer problems than we expect. If it turns out there are lots of little problems, probably best to read the code for an existing aggregator and imitate it as closely as we can. Though it's not clear that the existing ones are bug-free either.