added a couple of permutation algorithms and refactored some stuff