Several bugs fixed.