fix bug, add debugprints

The debugprints are temporary...
utf-8 encode before passing to C
better diags on error
remove debugprints, add assertions