Cleaned up a bit of garbage.
Fixed a few bugs for Darwin targets.
Fixed a memory leak.
Code cleanup.