added publish sd sample, corrected minor bugs