Updated to use shared functions
+improved output folder handling