various bug fixes and performance improvements found while working on SMC