Add join,rand to stack & simplify algorithms