Merge fix in main, delete duplicate code