Final code for upgrades

Everything is coded up now, changed a lot around, etc.