Fix bugs with form encoding and error handling.