simplified some published fns and fixed some bugs