fixes some bugs revealed by integration tests