Fixed attaching 'this' to EventListeners and some edge case fixes.