Optimizations and bugfix on a few events