strongly type attributes

**please review**
I can make a separate pull request for this if you want, but I don't really want to mix together large-scale refactorings with local modifications if I can help it.