Use new GCD functions for running blocks on the main thread

And various other commits that sneaked in.

The first is from am while back after a discussion on IRC about retaining/releasing when using `[NSMDict setObject:a forKey:b]`.

We found that if an object already exists for `b` it is released before `a` is retained, meaning that is `[NSMDict objectForKey:b] == a` then you could potentially over-release `a`