Misc fixes for bugs found while using in production