[Cin] Resource leaking and high memory usage