Fix exception caused by improper element.remove by moving it to setTimeout

Would like to fix #150