cleanup and fixes. (wip)