Fixes objects

Please review my commit, I thinks it hardens the code a bit, fixed some segfaults I was encountering while using objects instead of arrays