Functions used in my PhD thesis