Fix some indentions.
Move buffer creation out of formatting procedure.