Fix RouteElement leaks

Also fixes style issues.
Probably fixes the disabled cache, but I haven't tested.