Fixes and tests