add support for subdirectories, big refactor for private methods, add tests
3.0.0