Added some debug code and null case checks to publication.coffee