added closure variable debug which triggers printing of debug messages
disabled preventDefault in all handlers