bug and style fixes