implemented working token handling. Close #4