Found out every function that uses this has problems: when calling an object method as an input callback, this gets replaced with the element that triggered the event.
Also cleaned a few things, removed some unused variables