Fixes event ordering problems in browsers other than chrome

Fix for #169