Fix code so that types can be used, and use the type information from codemirror