Some fixes in type conversion