Refactored server side to use classes for handlers and emit using contexts and helper classes