Mainly rewrote some functions.
Double covers refactored, some old code cleaned up.