More housekeeping

Cleaned up more useless vars, added a few comments, fixed the kilojoule
bug yet again, revised the kilojoule calculation so that it is
variable-based.