Misc fixes, preparing for tests