Miscellaneous fixes.

Memory leaks and an early return.

Just pedantic stuff :p