broken code, segfault upon restarting game