set implementation, someplace ugly an buggy