Using FREE macro more.
Removed stale includes.
Fixed some errors when running on 32-bit Linux.