More merges from state branch.

Add -Wall to build config, add test dir, modularize functionality even more.