Add support for #3483

Also refactored state.py a bit and made some changes a long the way to support pydsl, plus fixed a bug in pillar/__init__.py.