bug fix for pull request 82, issue 90. s.bounds is now checked for null.
really?? OMG s.bounds not null not s..
more thorough undefined checks
merge from issue_90 feature