Rewrite to not use external .sh files