Simplifications and refactoring