Refactored lot of tabs code. Fixed some bugs. used good programming practices