fixed some bugs; work in progress