move P to class, add yaml-constructor