Fix bugs in formatting