Fix empty edge case; fix syntax errors; fix broken tests