Migrated over some changes from dotbash.