Several improvements to the code to handle saving posts.