Refactored and fixed the rewrites, added basic path rewrite