This code shouldn't be in the master...
Wow, a lot of weird code snuck in here.
And another bit of cleanup.