Fixed a couple bugs in the new code.