fix bad use of exec()
various changes to fix issues found during data import (sorting and filtering mainly)