Huge refactoring. Changed rotation algo, changed boundary.