Tidied up bin and str conversion functions