Various fixes and upgrades