Event handlers for challenge responses, various refactoring