fix not range-checked vector access
try to reign in the vector<ptr> madness
Merge pull request #187 from Bigpet/master

range-check and more explicit ownership with vector<ptr>