implemented generic lexicalError() and some cleaning in code