And a bunch of potential memory leaks, and some misbehavior that could occur due to not checking for errors properly. Signed-off-by: Christopher Snowhill <kode54@gmail.com>