Bug and code style fixes.