various bits and pieces of helpful code aquired over time. Candiful code hopefully.