Re-implemented a previous fix for automatic phase gate insertions, THT