some fixes. preparing to rewrite core.