added some int casts around qdists