Add dirname and basename.
Move suffix stuff into a function.