Refactoring to make it possible to support directories.
Now supports directories.
Single files work as well.