Added some scope checking for illegal lines.