numerous fixes + more debugging