needs lots more cleanup, but is much nicer than doing this by hand...
.permission parsing works, .config needs more work.