Fix a bug where the depth of module directories was calculated incorrectly