v0.5 complete rewrite