Minor code upgrades and refactoring
Small code quality improvment