A bunch of fixes related to #72.

Some logging errors are also resolved.