Refactored networking into a singleton class
Added comments