Add better bounds checking from Groovy Branch