Clean up common/lib.php

Drop $readwrite parameter from get token function
Clean up code