A lot of bugs fixes