Move event listeners into browser code