correct several bugs