Pull request to master

Wow, this is very useful (and clever). It looks cleaner now.