Various cleanups and two new features: