Implement per-function files
Almost working version