Refactor resource reloading based on filename into a function, which can be called externally.