Adding semi-decent logging support, needs a bit more testing