[IMP]Improved some code and removed unused chnages.