Declare dependency on selection
Remove dead code
Move event/history trigger to the right place