Complete rewrite done