Fixing query and format code.