Removed some calls to external programs in favor of sh string operations.