[minor] Added debug statements
[fix] Fixed a 99% CPU spin due to a missing directory pop.