Finalizing code refactoring. Removing duplicated code.