Fixed the schema and queries for codes