Intermediate work
Fixed bug in parsing the type of records
Master merge + further tweaking