bug 13: untested refactor of APNs logic (and more)