WIP: integrated more based on Tracy and Authrel work