Added multi-level directories [resolves #1789 and spent 3 hours on #1789]