Fix bug form for the case when there are less than 4 custom fields
Add SQLite support (FIXME: check if all UNIONs are ordering correctly)