Refactor PD to app class, updated tests.