major bugfixes to STM