Make modules unregister their callbacks on cleanup
Revert "Make do_log() default to printf when logprintf is not initialized"

This reverts commit 0727b58c63dc5cb6761d5a8806afe06b2e4fefe4.