Patched in Nathan's refactoring