Add Per-App profiles stuff; misc fixes and changes