Clean up, fix exit conditions, use std::vector of std::threads.