Some fixes for issues found in testing