Generate better badarg error in operators

Also took chance to do some small cleanups.
Improve string.format to handle more options
Fix string.format handling of integers
Break string formatting code into separate module
Fix string.format handling of floats
merge with rvirding/develop