Several bugfixes.
Removed log debugging.