Fixed insert/update transactions, fk issues.

Resolves issue #10.