Another stupid little coding mistake, made switching idblock types (like from object to scene) crash the script.