Further work and bugfixing

Found a stray global variable in one file which introduced hard to
track bugs, corrected now.