Fixed bugs in IMB script