It is no longer possible to manually set 0 or "" in primary key fields. Refactored error checking so it is more maintainable.