Setting some load and unload event handlers.