code cleanup
stop threads

REVIEW MULTITHREADING!