Refactoring to modern code