refactor and 64 bit problem fixed