Major updates to backend script.