Multiline formatting ported and small fixes