Refactored.
Added logging feature.
Refactored logging initialization.