Extract some functions into modules, more work needed
Remove unused variable initialitems
Extract addAsync to module and remove unnecessary variables
Move event initiation to corresponding module