Improve header and body generations for python and scala