Bug fixes and upgrades