New rewrite, start fixing up replace