Now adding n-1 
 and 
 tokens around line. Also some structuring to the code.
Removed legacy code.