bugs fixed

previously, there were bugs in these two subroutines (not small ones at
all!!...) which caused spurious behaviour; now fixed