add keyword var for local variables and some minor optimization