Add failed event, refactor some postmark code