New singletons-based architecture

Work-in-progress. This compiles & works, but I want to think a bit about how we can improve the API.

Closes #13, #25, #29, #36, #19.