extract addListener and removeListener to declaration and assignments
remove repetition of regex
move variables into single var statement
inline single-use var
catch up built version
expose emit method