Rewrite to be smooth and have more features