a few bug fixes and style changes