Fixed bugs in linked lists, added memset() to clear allocated memory