Refactored the majority of the program structure, fixed piping functionality and history