Fixed a memory leak and other minor errors.