Fixes for bugs #4 and #7