Refactor, mostly handling of listeners and mostly in order to better
facilitate detaching them.