Bugs and style fixes