Some useful utils rewritten on Apple's Swift