hacked in multhreaded support - needs severe clearing up