Copied in my own libraries for snarks