Merge fix IntegrityError branch (fix #12 among others)