Merge "Tweak shell thread and clean up some code" into sc-dev