More logging and moved addEventListener