Version 0.5: finished rewrite