Reorganized JS functions, Debugged frame material query in flask, etc.