Start implementing StateMonitor with code generation (not working yet)