fixed memory leak and form submission bug