 	openTransaction,
 	(request, response, next) ->
 		nameIsValid = lib.validation.characterNameIsValid(request.body.character_name)
-		alreadyExists = lib.character.characterExists.sync(null, request.uonline.tx, request.body.character_name)
+		alreadyExists = lib.character.characterExists.sync(null, request.uonline.db, request.body.character_name)
 
 		if nameIsValid and not alreadyExists
 			charid = lib.character.createCharacter.sync(
 				null
-				request.uonline.tx
+				request.uonline.db
 				request.uonline.user.id
 				request.body.character_name
 				request.body.character_race

	(request, response, next) ->
		usernameIsValid = lib.validation.usernameIsValid(request.body.username)
		passwordIsValid = lib.validation.passwordIsValid(request.body.password)
		userExists = lib.user.userExists.sync(null, request.uonline.tx, request.body.username)

		if usernameIsValid and passwordIsValid and !userExists
			result = lib.user.registerUser.sync(
				null
				request.uonline.tx
				request.body.username
				request.body.password
				'user'



fetchCharacter = ((request, response) ->
	character = lib.game.getCharacter.sync null, request.uonline.db, request.uonline.user.character_id
	request.uonline.character = character
).asyncMiddleware()


fetchCharacterFromURL = ((request, response) ->
	request.uonline.fetched_character = lib.game.getCharacter.sync null, request.uonline.db, request.params.name
).asyncMiddleware()


