add apns, code refactoring. Closes #15