Minor scripts refactorings