More bugs fixed, added powering of residues.