Mostly reconfigured some code and cleaned few lines.