Merge with sam's work. Some more wip.