Refactor build API and controller

Refactor the build API and validation. Refactor the build controller
to use the upstream cache package where possible. Use watches wherever
possible.