Moved some publishing stuff into separate functions