style fixes and other code fixes