Minor bug fixes

Fixes to counters, teleport, teleportbase, upgradebuilding, and
upgradeitem. Bugs found by Deon and Meph