perl tidy and fixes