Minor fixes or refactoring