Replace calls to dirname
Clean-up