                         throw ContextError.IdentifierAlreadyDeclared
                     } else {
                         AST.globalRecordTable[record.ident] = record
+                        AST.globalStoreTable[record.ident] = recordStore
                     }
                 }
                 
                 while(decl != nil){
                     let store:Store = try! decl!.check()
+                    
+                    store.ident = recordStore.ident + "." + store.ident
                     
                     if(isConst && store.isConst != isConst){
                         throw ContextError.RecordIsConstButNotTheirFields
                     }
                     
-                    let check = AST.scope!.storeTable[store.ident]
-                    if(check != nil) {
-                        AST.scope!.storeTable[store.ident] = store
-                        record.recordFields[store.ident] = store
+                    if(AST.scope != nil){
+                        let check = AST.scope!.storeTable[store.ident]
+                        if(check != nil) {
+                            throw ContextError.IdentifierAlreadyDeclared
+                        } else {
+                            AST.scope!.storeTable[store.ident] = store
+                            record.recordFields[store.ident] = store
+                        }
                     } else {
-                        throw ContextError.IdentifierAlreadyDeclared
+                        let check = AST.globalStoreTable[store.ident]
+                        if(check != nil) {
+                            throw ContextError.IdentifierAlreadyDeclared
+                        } else {
+                            AST.globalStoreTable[store.ident] = store
+                            record.recordFields[store.ident] = store
+                        }
                     }
                     
-                    decl = decl!.typedIdent.optionalRecordDecl
-                }
-                
-                AST.scope = oldScope
+                    decl = decl!.nextDecl as? AST.DeclarationStore
+                }
             } else {
                 let store:Store = Store(ident: typedIdent.ident, type: type, isConst: isConst)
                 if(AST.scope != nil){

        }
        
        func check(routine:Routine) throws {
            let store:Store = try! declarationStorage.check()
            var mechModeType:MechModeType = MechModeType.COPY
            let mechType = try! mechMode?.check()

            
            if(type == ValueType.RECORD){
                let record = Record(ident: typedIdent.ident)
                let recordStore = Store(ident: record.ident, type: type, isConst: isConst)
                
                var decl:DeclarationStore? = typedIdent.optionalRecordDecl!
                
