Code and style fixes