Added 64bit support, fixed segfault