First pass code rewrite.