Fixes for different bugs spotted