Fixed runaway threads. Small tweaks for running with Java server