Development

Took longer to get to this than I hoped. I think I have everything in here that you requested including unit tests. I think I covered pretty much every case I can think of, but I'm sure there is something I missed.