fixes for various bugs