Fix #229, add debugging for #228

Signed-off-by: Ross Allan <rallanpcl@gmail.com>