Improved exceptions. Added position to tokens and added 'end' token.