bug fixes on type conversion