Cleanup

More cleanup, notably trying to make the main() function read more self-explanatorily and consolidate redundant code in the file creation functions. Also updated framer.states.js for some Framer 3 API changes.