implemented the token service and did some sonar fixes