Fixes #879: Formbuilder enhancement

Fixes #879
Reduced database querying.