Improve javascript/java format routines