Added metahash count checking, minor debug fixes