Refactoring to defeat complexity problems