Version 2 -- a complete rewrite.