Added patch from https://gist.github.com/danmichaelo/894275
Patched using previously committed gist file.