proper free()s
all functions implemented, bugs present