Improvements and refactor,