Several misc fixes