rewrite from scratch (preparing for v0.2 release).