Fix errors in firstInLine calculations

Fixes #257 
Fixes #258