improve exceptions
add basic logging mechanism
fixes and tweaks