Mostly done, still some bugs to fix