Cleaned up the code and full import into the database