All manner of bugfixes