Use a manifest to store generated files

This allows us to remove trailing .beam files
when a file is removed and more robust compilation
detection.

Closes #717, closes #954