This potentially segfaults/throws, might need to do this in a safer way.