fix several small bugs