Merged changes and tests from chris