fixed several small bugs