Improvements to formatting numbers with more complex masks