Fixed weird event registration

This fixes click handlers on the document