A lot of bugs fixed