Reorganization & Cleanup

Also added test case for pipe parsing bug.