Several fixes, added socket init