Some simple changes and refactoring