Merge "Fix bugs in grain where values could go out of bounds." into jb-mr1-dev