updated debugging technique and removed minor bugs from caching