Memory leak & code cleanup

Eliminated unnecessary functions
Wrote new functions to help eliminate repetitive code
Cleaned up memory leaks
Added destroy_record() routines