Code cleanup

4 commits that cleanup code by using more shell built-ins.
please note that this line is not covered by tests, so you'd need to test it manually