Strip trailing slash from path to script
Fix bug where count cant be zero