Refactoring done, code is simpler.