 		return res.send(500)  unless database
 
 		# Serve the document to the user
-		document = database.findOne(relativeOutPath: '404.html')
+		document = database.findOne({relativeOutPath: '404.html'})
 		docpad.serveDocument({document,req,res,next,statusCode:404})
 
-	# Server Middleware: 404
- 	serverMiddleware500: (err,req,res,next) =>
+	# Server Middleware: 500
+	serverMiddleware500: (err,req,res,next) =>
 		# Prepare
 		docpad = @
 		database = docpad.getDatabase()

		return res.send(500)  unless database

		# Serve the document to the user
		document = database.findOne(relativeOutPath: '500.html')
		docpad.serveDocument({document,req,res,next,statusCode:500,err})

	# Server
	server: (opts,next) =>

		_.each @config.collections, (fn,name) ->
			tasks.push (complete) ->
				if fn.length is 2 # callback
					fn.call docpad, database, (err,collection) ->
						docpad.error(err)  if err
						if collection
							collection.live(true)  # make it a live collection
							docpad.setCollection(name,collection)  # apply the collection
						complete()
				else
					collection = fn.call(docpad,database)
					if collection
						collection.live(true)  # make it a live collection
						docpad.setCollection(name,collection)  # apply the collection
