                 callback null, body.hits[0].id_hash # One result, simple!
               else
                 # Results are ambiguous, things get *way* more complicated.
-                mkdir './picksel_temp', (error) -> # Create temporary folder.
-                  if error
-                    callback error, null # Couldn't create folder.
-                  else
-                    downloadHits body.hits, (err, files) ->
-                      matchImage base, files, (err, percs) ->
-                        rimraf './picksel_temp', fs, () ->
-                          #WUT
-                        rimraf './pickseltemp_base.jpg', fs, () ->
-                          #WUT
-                        callback null, closestMatch(percs).hash
+                resolveAmbiguousResults base, body.hits, callback
             else
               callback error, null # Error during search.
     else


# Checks whether or not a human-readable resolution name is valid.
#
# @param [Number] resolution the resolution code to check.
#
isValidResolutionCode = (resolution) -> humanResolutionToCode(resolution) > -1


# Persists an object to a file as JSON.

#
# @param [String] apiKey the API key to use for the request
# @param [Number] id the ID of the image to get information for
# @param [String] resolution the human-readable resolution required
#
buildUrl = (apiKey, id, resolution) ->
  code = humanResolutionToCode resolution
