enum support & refactor. fixes #12 and #14