Fixes for issues #198, #201, #202, #203