a few fixes + sanity test