Split read row into subroutines.
rename functions.
Add documenatation and assert to ensure correct usage.
Improve error reporting.
Small corrections.