Bunch of bugs fixed