update to new appcp; some refactoring