Move brstack to its own file and add convenience types