Added a bounds check to the drawShape() + changes missing from the previous commit.