Minor code corrections and style fixes