Rewrite unique_mapping , fix the annoying memory leak.