Some code refactoring / changes