First stage for the client rewrite