Refactor add event listeners, fix #6