Moved api server prepared statement creation closer to where they are used