Fix some issues found whilst testing