Fix API routes
Format some API code