Bits and pieces of useful functions