Moved some event handlers into external files