Big update, got it running without mem leaks