improved APNs module with logging