Some more refactoring and fixing. Next step: Remove the line model...