Fixed various issues, rename functions to use "xxx_toYYY" where appropriate