Fixing and refactoring