Several bug fixes to the last commit.  I think this might actually be working as intended now.