Refactor rest extension. Improve bootstrapping