Docker and fig support for local development plus code refactor

Includes a bug fix as well.