Swift casting fixes