Added/improve logic

Added upgrade building logic, and improved some older code.
Next will be finish an upgrade.