Account flags

Closes #278
Accidentally contains commits from #338