minor fixes and rearrangements