Fixed Segment Problem, cleaned up out of bounds checking

I don't know what was going on. https://gist.github.com/abramsba/6090972 shows the gdb and valgrind output from a debug session. For whatever reason the instances were created but the instance was removed right before reaching the init and I'm not entirely sure why. Moving the code around work.

Oh and I cleaned up the generation code anyway so it's a bit clear so we can modify it later.