Categorical Components

This is a cleanup of #213. It fixes a few failing tests and PEP8 failures, and should merge cleanly onto master