Fixed errors and wrong variable declarations