Cleanup and optimization of code in ModShell7Base.