Separated the flash and js. Also cam is freed after snapshot.