Refactor the filesystem plugin