Refactoring, remove some allocations