Bug fixes and style tweaks