Form, socket and ajax fixes