Code refactored.
Resolved merge issues