more casting fixes