Fixed possible bug if filename has no directory component.