use logmagic; fix some bugs introduced in previous commits