Fixes to bugs introduced in 76a60ed
Added logging engine for #61