Lots of functions written up, two more to go
They are difficult ones though, so seperate commits