Roughly finished, still needs testing