fixed SQL renaming bugs