Some minor refactorings before dealing with uploaded binary resources