Refactored module to follow event handling best practises.