malloc checks for nodes, also fixed #5 and fixed #6