fix dirname to handle input of form "foo/" correctly also optimized a bit.
initial check-in, version 0.5.0