Make formatter a bit more robust (fixes issue121).