fixed some bugs that would prevent sm executing