Miscellaneous fixes

A few issues with `cond_var` and add a `memset` implementation which allows things to compile with `--opt-level=0`