Code review updates

These are updates based on your code review so far.  I put them in a branch off of channelwad.
Moved this block of code into its own function.