switch to using signed big integers and reorganize