Revert to using our own constants when setting up authmode and client mode
Re-add free() methods for freeing objects.