Small refactoring and code cleaning