Fixed sequence problems and id=0 problems here

This should fix the PUT problem, but POST is due to not updating foreign key.