Improvements and refactoring...