adding encoding threads and stuff