fix statement printing and add return statements to generated functions