Fixing rewrite... WIP.
Minor clean ups.