Some small code refactoring