bring back trim_trailing_whitespace and insert_final_newline support

This brings back trim_trailing_whitespace and insert_final_newline support. I would however postpone merging it until we publish new version with exception fixes and new java core