inlined a bunch of while loops in hot paths of read/writing case classes