Rewrite runtime to be prototype-based and minimal

This is a complete rewrite of the previous version of Metal
with a prototype-based object model and a much more lightweight
library.