Cleaning up directory and counter code