Fixed perf issue with large shell inputs