Debugging and refactoring in progress...