added "state" and "bodynewlines" parameters