Fixed stdout and stderr to be <pre> tags, changed qsort to mergesort, and added event handling.