fixed crash when path contains no slashes.

used basename() instead of manual parsing.