fix typos in comments, signal more specific error types, remove some stale code, fix a few compiler warnings in the runtime.