Various fixes to improve form handling