Refactor to make pretty

Fixed a few logic errors, generalized a couple paths, and correctly called the
new bash function.