changed client structure and cleaned up