It seems like there are some errors in logic of your Upgrader-creep. If you check amount of energy every tick and order your creep to go harvest missing amount, creep will finish upgrade until its done even after the first tick, because he already wasted 1-2 energy for upgrading.