Fixed line counting problem and removed 100 lines

Fixed a problem were some lines were not counted when searching for the
next variable name, and removed about a 100 lines of code that were
useless.