Refactor resource background loading into a separate class.