Fixed a few bugs found in integration