Need to fix segfaults badly! And fix memory leaks with it