Fixes bug when migrating from MySQL DBMS. Also a minor enhancement.