Unify the string->amount convertion code