Patch for TS-2652: Cleaning up correctly and removed some debug lines