Finished most of debugging, TODO: fix sub bits, sometimes gets over 256 bits