Fix several issues found during testing