Fixed reference error and changed some memcpy's to assignments.