Simplifying log handling.
Fixing some bugs.