Code: fixed formating issues
Fixed some memory leaks