a few bug fixes + debugging