fix referentials corruption and removed some debugging