Fixed id dictionary inserting in wrong direction