BUGFIX: Better handling of directories