Fix bugs in number formatting