Most of the function is there, still needs some polishing.