Added in proper resistance calculation
Tweaked energy distribution code