Fix for savannah bug report 87728 (Laurent) + fix invalid read found with valgrind...