Refactor file manager JS into its own file, and beautify it