Moved event handlers to scripts