Switched over to using the GNU version of basename().
POSIX version of basename is currently segfaulting.
TIL don't pass POSIX basename() a static string.