Fixed #3: Add events to hook into the query and scan commands.