A few useful code snippits from along the way