Fixed most of bugs