moving similar logic to a base class, switching to use joi for schema validation instead of json schema
fixing several bugs