Event handling functionality separated out into module.