optimize top level schema and code style