Merge hmc code into a library