add more debugging and fix subdirectory path creation