Bring in some bugfixes and reorganize