Misc changes and tests