Switched to malloc instead of VLAs and fixed an signed/unsigned bug in addressing.