Fixed a pretty serious bug in withinBound. It was never triggered but
still pretty dumb.
Incremental improvements, added a couple of functions.