I have fixed quite a few important bugs in this commit.