Massive re-write!

Takes advantage of then() capabilities and is much more robust! Thanks
for feedback from everyone in first pass.