fixing several small bugs