Fixes found by unit tests