As a result of the thread at
I've made some additions and minor corrections of the code (primarily enum and capability elements).