Removed unused require and import. Handle the res.nil case in
execute_command() and authenticate().