bugfixes to procedures