fix some bugs, start work on #16