CORE-3882: fixed several bugs that I found during testing