Fixed broken file browser (empty path levels)

And refactored a bit