More defensive programming, changing my mind about casts.
Breaking out timing stuff