add mining and fix server client handling