First attempt at fixing what issue #225 turned into

As per discussion in #225, this is what I think this should look like.

@nathj07: I would appreciate it if you could run your application against this branch.  But please keep an eye on it if you do, as I haven't yet looked at this code for long enough to commit to master.

Also, code review would be very much appreciated, by anyone.