Fixed braindead memory leaks and simplified the parse_xxlist() functions