Fixed somewhat-too-drastic refactoring