Catching invalid tokens and avoid nullpointerexceptions.