Add preview feature, plus a few more cleanups.