Formatting code to be more standard, fixed a null delegate bug.