Moved part of create_schema function to separate functions.