Reorder some queries

This way it doesn't tie up when changing the table name because the
table doesn't exist yet. Rarely happens, but could happen. Not anymore.