 	# Get Files (will use live collections)
 	getFiles: (query,sorting,paging) ->
 		key = JSON.stringify({query,sorting,paging})
-		result = @getCollection(key)
-		unless result
-			result = @getDatabase().findAllLive(query,sorting,paging)
-			@setCollection(key, result)
-		return result
+		files = @getCollection(key)
+		unless files
+			files = @getDatabase().findAllLive(query,sorting,paging)
+			@setCollection(key, files)
+		return files
 
 	# Get another file's model based on a relative path
 	getFile: (query,sorting,paging) ->
-		result = @getDatabase().findOne(query,sorting,paging)
-		return result
+		file = @getDatabase().findOne(query,sorting,paging)
+		return file
 
 	# Get Files At Path
 	getFilesAtPath: (path,sorting,paging) ->
 		query = $or: [{relativePath: $startsWith: path}, {fullPath: $startsWith: path}]
-		result = @getFiles(query,sorting,paging)
-		return result
+		files = @getFiles(query,sorting,paging)
+		return files
 
 	# Get another file's model based on a relative path
 	getFileAtPath: (path,sorting,paging) ->
-		result = @getDatabase().fuzzyFindOne(path,sorting,paging)
-		return result
+		file = @getDatabase().fuzzyFindOne(path,sorting,paging)
+		return file
 
 	# Get a file by its url
-	getFileByUrl: (url) ->
-		result = @getDatabase().get(@filesByUrl[url])
-		return result
+	getFileByUrl: (url,opts={}) ->
+		opts.collection ?= @getDatabase()
+		file = opts.collection.get(@filesByUrl[url])
+		return file
 
 	# Get a file by its selector
-	getFileBySelector: (selector,opts) ->
+	getFileBySelector: (selector,opts={}) ->
 		opts.collection ?= @getDatabase()
-		result = collection.get(@filesBySelector[selector])
-		unless result
-			result = collection.fuzzyFindOne(selector)
-			if result
-				@filesBySelector[selector] = result.id
-		return result
+		file = opts.collection.get(@filesBySelector[selector])
+		unless file
+			file = opts.collection.fuzzyFindOne(selector)
+			if file
+				@filesBySelector[selector] = file.id
+		return file
 
 
 	# ---------------------------------

		# Prepare
		[opts,next] = balUtil.extractOptsAndCallback(opts,next)
		docpad = @
		docpad.lastGenerate ?= new Date('1970')
		locale = @getLocale()
		opts.reset ?= true


	serverMiddleware500: (err,req,res,next) =>
		# Prepare
		docpad = @
		database = docpad.getDatabaseCache()

		# Check
		return res.send(500)  unless database
