fixed two important bugs.