First big old commit. Mostly moving stuff from other branches for reorganization.