@Override
		public GCodeStore loadGcodeModel(InputStream in, long fsize)throws IOException{
			GCodeStore codes = createStore(100000);
			readbytes=0;
			readlines=0;
			filesize=fsize;
			InputStreamReader fread =  new InputStreamReader(in);
			BufferedReader gcread= new BufferedReader(fread,65536);
		
			String line;
			String errors = "Error while parsing gcodes:\n";
			int idx=1;
			int errorcnt=0, success=0;
			long time = System.currentTimeMillis();
			
			try{
			while((line=gcread.readLine())!=null){
				GCode gc = null;
				try {
					gc = parseGcode(line, idx++);
				} catch (Exception e) {
					e.printStackTrace();
					System.err.println("Error while parsing gcode:"+line+" (line:"+idx+")");
				}
				if(gc == null || gc.getGcode() == GCDEF.UNKNOWN){
						errorcnt++;
						errors = errors + ("Error #"+errorcnt+" at line:"+idx+" Content:'"+line+"'\n");
						if(errorcnt-success > 10 || gc == null){
							gcread.close();
							throw new IOException(errors);
						}	
				}else{ 
					success++;
				}
				codes.add(gc);
				readbytes+=line.length()+1; //might be incorrect for multibyte chars, but getbytes is expensive
				readlines++;
				
			}
			}catch(OutOfMemoryError oom){
				throw new IOException("Out of Memory Error");
			}
			if(success == 0){
				throw new IOException("No valid Gcode line found");
			}
			gcread.close();
			codes.commit();
			System.out.println("Load Model finished in ms:"+(System.currentTimeMillis()-time));
			if(errorcnt != 0){
				System.err.println("Detected "+errorcnt+" error(s) during parsing of Gcode file. Results might be wrong.");
			}
			m101=false;
			return codes;
		}