Added debug mode and reestructured client module