various fixes including variable declarations