Refactored eventlisteners

Made code inside to seperate funcitons reachable from other classes.