fixes for negative indexes in substr()
indexOf fixes