Fixed bugs in initialization.