a number of small fixes for related bugs. fixes #10, fixes #14, fixes #15, fixes #16