Refactored fork/exec code

In preparation for implementing piping multiple commands.
Added loop in fork to parse piped commands