Common functions and snippits for R