Merge http://gist.github.com/3305554