Fix bug that causes confusing invalid argument errors