Properly allocating memory for tokens