Small refactoring; patch from nus