Small optimization and style fixes