fixes for various bugs

see commits for details..