Fixed many segmentation faults (previously undetected due to javascript cross-compiling)