little fixes (made some variables local)