checking for errors in model before generating code. Should fix #41