source refactoring to allow more flexible form process logic(also add plenty of java docs).