Fixes a couple issues found in adapting this to Dart.