Added bounding box support, fixed some bugs, cleaned up in general.