Link the undelivereds with the delivered.

Also a couple of code cleanup things.
Need to maintain the this argument.
Merge pull request #75 from tidepool-org/cheddar/link-undelivered

Link the undelivereds with the delivered.