Refactoring the problems one by one.