Move some tokenizing functions to utils

Change-Id: Ibbf72ebfeb62493b51f20ea29f814708db9bd4a2