Made changes to remove duplicate funtions. Also split several files into appropriate header and cpp files for modular design.