Bug fixes and minor polishes