Restructure to support recursion, fix indention
Full recursive pipe handling!