Fix scope problems with posts and remove unneeded code