Latest round of patches and core code for RefID