many changes that fix LFS bugs and make implicit casts explicit