Went and properly implemented POSIX compliant chdir(...) and getcwd(...) functions to maintain the terminals current working directory.