port changes from vector branch, #23