Fixes broken tests and bugs from last commit