[LMP] Slight code style changes.
[LMP] Never disable foreign_keys, move deffering into transaction instead.

For some reason SQLite doesn't reenable foreign keys back on after
transaction finishes.

Fixes #1688.