Optimal space usage. Refactoring.