Fixed ancient bug in composition calc, and cleaned up a bit