Fixed memory leaks and file closing bug.

- Fixed a bug in the closing of files in the Storage Engine: the engine
  would close the current file, then try to close it again, causing
  random data to be printed to stdout.
- Added calls to delete that were missing: fixed a few memory leaks.
- Renamed a bunch of LOG_* calls to use the correct class/method.