Fixed inaccurate comment
Fixed memory leaks and added error checking
Merge pull request #1 from Sc00bz/patch-1

Fixed inaccurate comment, memory leaks, and added error checking