sm bug fixes and cleanup