Cleaned up formatting function.