Fix the destroy bug (an event didn't get detached).
Do some refactoring.