Bug fixes (make tests pass)