Bug fixes from quant opt