Fixed some bugs regardign the rewrite
: