Spend 90% of your time solving real problems until it becomes a drag. Then refactor for a month, rinse and repeat.
Discussion
That percentage will drop every cycle, until you're spending 10% of your time solving real problems and 90% of your time doing maintenance.