Refactoring wal_log_util

Cleaned up some of the code and
refactored it.