Fix multiple bugs

- Fix duplication
- Fix event undefined in firefox